package com.android.fragmentdemo
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.databinding.DataBindingUtil
import androidx.viewbinding.ViewBinding

inline fun <reified T : Activity> Context?.startActivity() {
    this?.startActivity(Intent(this, T::class.java))
}

fun Context.showToast(content: String) = Toast.makeText(this,content, Toast.LENGTH_SHORT).show()

fun <T : ViewBinding> ViewGroup.findBinding(layoutId:Int) : T {
    return DataBindingUtil.inflate(LayoutInflater.from(this.context), layoutId, this, false)
}

fun View.setVisibilityState(visible: Boolean) {
    visibility = if (visible) View.VISIBLE else View.GONE
}